package com.lcx.plugin.factory;

import com.intellij.openapi.ui.Messages;
import com.lcx.plugin.dict.GlobalDict;
import com.lcx.plugin.enums.DatabaseType;
import com.lcx.plugin.service.SqlHandleService;
import com.lcx.plugin.service.impl.MySqlHandleServiceImpl;

import java.util.Objects;

/**
 * 简单工厂模式
 *
 * @author daxiong
 * @date 2023/6/21 上午11:04
 */
public class SqlHandleFactory {

    public static SqlHandleService getSqlHandleServiceByDbType(String dbType) {
        DatabaseType databaseType = DatabaseType.getByDbType(dbType);
        if (Objects.isNull(databaseType)) {
            Messages.showWarningDialog("不支持的数据库类型！！", GlobalDict.TITLE_INFO);
            return null;
        }
        switch (databaseType) {
            case MYSQL:
                return new MySqlHandleServiceImpl();
            default:
                return null;
        }

    }
}
